package gripper.ftp;

public class PathConvert {
	public static String toServerPath(String root, String path) {
		String newpath = root + path;
		String osName = System.getProperty("os.name").toLowerCase();
		if (osName.toLowerCase().startsWith("win")) {
			newpath = newpath.replace("/", "\\");
			newpath = newpath.replace("\\\\", "\\");
		} else {
			newpath = newpath.replace("//", "/");
		}

		return newpath;
	}

	public static String toFtpPath(String root, String serverPath) {
		String newpath = serverPath.substring(root.length());
		newpath = "/" + newpath;
		String osName = System.getProperty("os.name").toLowerCase();
		if (osName.toLowerCase().startsWith("win")) {
			newpath = newpath.replace("\\", "/");
		}
		return newpath;
	}

}
